﻿// See https://aka.ms/new-console-template for more information
//Console.WriteLine("Hello, World!");

//以下三个引用是 反射需要的 
using ReflectionAndMetadata;
using System;
using System.Diagnostics;
using System.Reflection;
using System.Reflection.Emit;

/*Type t1 = DateTime.Now.GetType();
Type t2 = typeof(DateTime);
Type t3 = typeof(DateTime[]); // 一维数组
Type t4 = typeof(DateTime[,]); // 二维数组
Type t5 = typeof(Dictionary<int, int>); // 泛型类型
Type t6 = typeof(Dictionary<,>); // 

Type t = Type.GetType("System.Int32,System.Private.CoreLib");

// 通过 Type 类型 查看这里类型的名称，程序集，基础类型，可见性 等等。
Type stringType = typeof(string);
string name = stringType.Name;  // String
Type baseType = stringType.BaseType; // Typeof(Object)
Assembly assem = stringType.Assembly; // System.Private.CoreLib
bool isPublic = stringType.IsPublic; // true


Type stringType = typeof(string);
string name = stringType.Name;
Type baeType = stringType.GetTypeInfo().BaseType;
Assembly assem = stringType.GetTypeInfo().Assembly;
bool isPublic = stringType.GetTypeInfo().IsPublic;*/

/*// Obtaining array types
Type simpleArrayType = typeof(int).MakeArrayType(); // 获取 int[] 类型
Console.WriteLine(simpleArrayType == typeof(int[]));

Type cubeType = typeof(int).MakeArrayType(3);
Console.WriteLine(cubeType == typeof(int[,,]));

Type e = typeof(int[]).GetElementType(); // 获取类型
Console.WriteLine(e==typeof(int));

int rank = typeof(int[,,]).GetArrayRank();
Console.WriteLine(rank); // 获得 3  表示是三维数组

// 获取嵌套类型
foreach (Type type in typeof(System.Environment).GetNestedTypes())
{
    Console.WriteLine(type.FullName);
}
Console.WriteLine("********");
foreach (Type type1 in typeof(System.Environment).GetTypeInfo().DeclaredNestedTypes)
{
    Debug.WriteLine(type1.FullName);
    Console.WriteLine(type1.FullName);
}

Type t = typeof(System.Environment.SpecialFolder);
Console.WriteLine(t.IsPublic);
Console.WriteLine(t.IsNestedPublic);
*/

//Type Names
/*Type t = typeof(System.Text.StringBuilder);
Console.WriteLine(t.Namespace);
Console.WriteLine(t.Name);
Console.WriteLine(t.FullName);*/

// Nested type names
//Type t = typeof(System.Environment.SpecialFolder);
//Console.WriteLine(t.Namespace);
//Console.WriteLine(t.Name);
//Console.WriteLine(t.FullName); // System.Environment+SpecialFolder

//Generic type names
//Type t = typeof(Dictionary<,>);
//Console.WriteLine(t.Name);
//Console.WriteLine(t.FullName);
//Console.WriteLine(typeof(Dictionary<int, string>)); // System.Collections.Generic.Dictionary`2[System.Int32,System.String]

// Array and pointer type names
//Console.WriteLine(typeof(int[]).Name);
//Console.WriteLine(typeof(int[,]).Name);
//Console.WriteLine(typeof(int[,]).FullName);
//Console.WriteLine(typeof(byte*).Name);

//Type base1 = typeof(System.String).BaseType;
//Console.WriteLine(base1.Name);
//Type base2 = typeof(System.IO.FileStream).BaseType;
//Console.WriteLine(base2.Name);
//foreach (Type iType in typeof(Guid).GetInterfaces())
//{
//    Console.WriteLine(iType.Name);
//}


//object obj = Guid.NewGuid();
//Type target = typeof(IFormattable);
//bool isTrue = obj is IFormattable;
//bool alsoTrue = target.IsInstanceOfType(obj);

//Type target = typeof(IComparable), source = typeof(string);
//Console.WriteLine(target.IsAssignableFrom(source));

//ConstructorInfo ci = typeof(List<>).GetConstructor(new Type[] { typeof(int), typeof(string) });
//object foo = ci.Invoke(new object[] { null });
//ConstructorInfo cti = typeof(XmlWriterTraceListener).GetTypeInfo().DeclaredConstructors.FirstOrDefault(c => c.GetParameters().Length == 1 && c.GetParameters()[0].ParameterType == typeof(string));

//Delegate.CreateDelegate

// 下面的例子构造了一个实例化的委托，和一个静态的委托
//ActivatorCreateInstance.ShowThread();

//Console.ReadLine();

//AdvancedThreading.Show();

//await ParallelProgramming.Show();

ParallelProgramming.Shw2();

